package com.example.springboot.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.springboot.common.Result;
import com.example.springboot.entity.HomestayCategory;
import com.example.springboot.service.IHomestayCategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 分类表 API控制器 - 不需要token验证的API
 * </p>
 *
 * @author
 */
@RestController
@RequestMapping("/api/homestayCategory")
public class HomestayCategoryApi {


    @Resource
    private IHomestayCategoryService iHomestayCategoryService;

    //查询分类
    @GetMapping("/list")
    public Result list() {
        return Result.success(iHomestayCategoryService.list());
    }


    @GetMapping("/{id}")
    public Result getByCategoryId(@PathVariable Integer id) {
        QueryWrapper<HomestayCategory> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        return Result.success(iHomestayCategoryService.list(queryWrapper));
    }

}
